package priv.stones.multi_thread.callable;

import java.util.concurrent.Callable;

/**
 * @Author: Stones
 * @Description:
 * @Date: 2017/9/20 16:23
 */
public class Callable1 implements Callable<String> {

    private Integer ticket = 5;

    @Override
    public String call() throws Exception {
        System.out.println(Thread.currentThread().getName());
        Thread.sleep(10000);

        for (int i = 0; i < 10; i++) {
            if (ticket <= 0) {
                System.out.println("票卖完了");
            } else {
                System.out.println(i + "还剩" + --ticket + "张票");
            }
        }
        return "--------------------------执行完了";
    }


}
